using System;
using UnityEngine;

[Serializable]
public class LatLong_Conversion : MonoBehaviour
{
	public global_settings_tc global_script;

	public latlong_class latlong_center;

	public latlong_class[] latlong;

	public Vector2 offset;

	public LatLong_Conversion()
	{
		latlong_center = new latlong_class();
		offset = new Vector2(0f, -27f);
	}

	public void Start()
	{
		int num = 0;
		latlong[2].latitude = 49.345443725585938;
		latlong[2].longitude = -119.57958221435547;
		int i = 0;
		latlong_class[] array = latlong;
		for (int length = array.Length; i < length; i++)
		{
			Vector2 vector = calc_position(array[i].latitude, array[i].longitude);
			GameObject gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
			gameObject.transform.position = new Vector3(vector.x, 0f, vector.y);
			Vector2 vector2 = calc_latlong(gameObject.transform.position);
			string lhs = vector2.x + " : ";
			Vector2 vector3 = calc_latlong(gameObject.transform.position);
			UnityEngine.Debug.Log(lhs + vector3.y);
			gameObject.name = "Test point " + num;
			num++;
		}
	}

	public Vector2 calc_latlong(Vector3 pos)
	{
		map_pixel_class map_pixel_class = new map_pixel_class();
		map_pixel_class map_pixel_class2 = global_script.latlong_to_pixel2(latlong_center, 19.0);
		double num = global_script.calc_latlong_area_resolution(latlong_center, 19.0);
		map_pixel_class.x = (double)(pos.x - offset.x) / num + map_pixel_class2.x;
		map_pixel_class.y = (double)(0f - (pos.z - offset.y)) / num + map_pixel_class2.y;
		latlong_class latlong_class = global_script.pixel_to_latlong2(map_pixel_class, 19.0);
		return new Vector2((float)latlong_class.longitude, (float)latlong_class.latitude);
	}

	public Vector2 calc_position(double lat, double lon)
	{
		latlong_class latlong_class = new latlong_class(lat, lon);
		Vector2 vector = default(Vector2);
		map_pixel_class map_pixel_class = global_script.latlong_to_pixel2(latlong_class, 19.0);
		map_pixel_class map_pixel_class2 = global_script.latlong_to_pixel2(latlong_center, 19.0);
		double num = global_script.calc_latlong_area_resolution(latlong_center, 19.0);
		vector.x = (float)((map_pixel_class.x - map_pixel_class2.x) * num);
		vector.y = (float)((0.0 - map_pixel_class.y + map_pixel_class2.y) * num);
		vector += offset;
		return vector;
	}

	public void Main()
	{
	}
}
